﻿@using DCMS.Core.Domain.Common;
@using DCMS.ViewModel.Models.WareHouses;
@model WareHouseModel;

<input asp-for="Id" type="hidden" />
<div class="form-group">
    <lable class="col-lg-2 control-label">
        仓库名称
        <i class="fa fa-exclamation-circle text-warning fa-lg" data-placement="top" data-toggle="tooltip" title="" data-original-title="仓库名称"></i>
    </lable>
    <div class="col-lg-9">
        <dcms-editor asp-for="Name" />
    </div>
</div>
<div class="form-group">
    <lable class="col-lg-2 control-label">
        仓库代码
        <i class="fa fa-exclamation-circle text-warning fa-lg" data-placement="top" data-toggle="tooltip" title="" data-original-title="仓库代码"></i>
    </lable>
    <div class="col-lg-9">
        <dcms-editor asp-for="Code" />
    </div>
</div>
<div class="form-group">
    <lable class="col-lg-2 control-label">
        类型
        <i class="fa fa-exclamation-circle text-warning fa-lg" data-placement="top" data-toggle="tooltip" title="" data-original-title="类型"></i>
    </lable>
    <div class="col-lg-9">
        @if (Model.IsSystem)
        {
            @Html.RadioButton("Type", "1", Model.Type != 2, new { id = "Type0", @checked = "checked", @readonly = "readonly" }) <text>仓库</text>
            @Html.RadioButton("Type", "2", Model.Type == 2, new { id = "Type1", @class = "mt15", @readonly = "readonly" }) <text>车辆</text>
        }
        else
        {
            @Html.RadioButton("Type", "1", Model.Type != 2, new { id = "Type0", @checked = "checked" })<text>仓库</text>
            @Html.RadioButton("Type", "2", Model.Type == 2, new { id = "Type1", @class = "mt15" }) <text> 车辆 </text>
        }

    </div>
</div>
<div class="form-group">
    <lable class="col-lg-2 control-label">
        允许负库存
        <i class="fa fa-exclamation-circle text-warning fa-lg" data-placement="top" data-toggle="tooltip" title="" data-original-title="不勾选时，则审核/红冲影响实际库存类单据时，不允许出现负库存。（包括：销售单，退货单，采购单，采购退货单，调拨单，盘点盈亏单，报损单，组合单，拆分单）"></i>
    </lable>
    <div class="col-lg-9">
        @Html.CheckBoxFor(model => model.AllowNegativeInventory, new { @class = "mt15" })
    </div>
</div>

<div class="form-group">
    <lable class="col-lg-2 control-label">
        允许负库存预售
        <i class="fa fa-exclamation-circle text-warning fa-lg" data-placement="top" data-toggle="tooltip" title="" data-original-title="不勾选时，审核预售类单据，预售数量不能超过库存数量（包括：销售订单）"></i>
    </lable>
    <div class="col-lg-9">
        @Html.CheckBoxFor(model => model.AllowNegativeInventoryPreSale, new { @class = "mt15" })
    </div>
</div>

<div class="form-group">
    <lable class="col-lg-2 control-label">
        状态
        <i class="fa fa-exclamation-circle text-warning fa-lg" data-placement="top" data-toggle="tooltip" title="" data-original-title="正常、停用"></i>
    </lable>
    <div class="col-lg-9">
        @Html.CheckBoxFor(model => model.Status, new { @class = "mt15" })
    </div>
</div>

<div class="form-group">
    <lable class="col-lg-2 control-label">
        访问权限
        <i class="fa fa-exclamation-circle text-warning fa-lg" data-placement="top" data-toggle="tooltip" title="" data-original-title="为仓库指定员工和单据"></i>
    </lable>
    <div class="col-lg-9">
        <table class="table table-striped table-bordered table-hover" cellspacing="0" cellpadding="0">
            <tbody>
                <tr style="background:#f2f2f2;" align="center">
                    <th rowspan="3" style="box-sizing: border-box;">总仓库</th>
                    <th colspan="11" style="box-sizing: border-box;" align="center">
                        开单：开单时员工可以选择相应订单，库存查询：开单和库存查询时可以查看库存量
                    </th>
                    <th rowspan="2" style="box-sizing: border-box;" align="center">库存查询</th>
                </tr>
                <tr style="background:#f2f2f2;" align="center">
                    @{
                        var types = Enum.GetValues(typeof(WHAEnum)).Cast<WHAEnum>();
                        foreach (var t in types)
                        {
                            <td>
                                @CommonHelper.GetEnumDescription(t)
                            </td>
                        }
                    }
                </tr>
                <tr align="center">
                    @{
                        foreach (var t in types)
                        {
                            <td>
                                <input type="checkbox" id="chkAllByType_@((int)t)" name="chkAllByType" data-id="@((int)t)" style="vertical-align:middle;" >
                                <label for="chkAllByType_@((int)t)">全选</label>
                            </td>
                        }
                    }
                    <td><input type="checkbox" id="chkAllStockquery" name="chkAllStockquery" style="vertical-align:middle;">
                        <label for="chkAllStockquery">全选</label>
                    </td>
                </tr>

                @foreach (var u in Model.WareHouseAccess)
                {
                    <tr>
                        <td>@u.UserName</td>
                        @foreach (var t in u.BillTypes)
                        {
                            <td align="center">
                                <input type="checkbox" id="makebill_@(t.BillTypeId+"_"+u.UserId)" name="makebill_@(t.BillTypeId+"_"+u.UserId)" style="vertical-align:middle;" data-userid="@u.UserId" data-billtypeid="@t.BillTypeId" value="@t.Selected" @(t.Selected ? "checked" : "")>
                            </td>
                        }
                        <td align="center"><input type="checkbox" id="stockquery_@u.UserId" name="stockquery_@u.UserId" style="vertical-align:middle;" data-userid="@u.UserId" value="@u.StockQuery" @(u.StockQuery ? "checked" : "")></td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
</div>